﻿using Entities;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Text;
using Utils;

namespace Bridges
{
    [ClassInterface(ClassInterfaceType.None)]
    [ComVisible(true)]
    public class Init
    {
        public string Index()
        {
            //SqlSugarHelper.Db.CodeFirst.InitTables<UserEntity>();
            //SqlSugarHelper.Db.CodeFirst.InitTables<ProjectEntity>();

            Debug.WriteLine(JsonConvert.SerializeObject(new
            {
                StatusCode = 200,
                Succeeded = true,
                Data = SqlSugarHelper.Db.DbMaintenance.GetTableInfoList(false),
                Errors = "",
                Extras = new { },
                Timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
            }));
            return JsonConvert.SerializeObject(new
            {
                StatusCode = 200,
                Succeeded = true,
                Data = SqlSugarHelper.Db.DbMaintenance.GetTableInfoList(false),
                Errors = "",
                Extras = new { },
                Timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
            }, new JsonSerializerSettings { DateFormatString = "yyyy-MM-dd HH:mm:ss" });
        }
    }
}
